import babelpolyfill from 'babel-polyfill';
import Vue from 'vue';
import iView from 'iview';
import Vue2Filters from 'vue2-filters';
import App from './App';
import axios from './axios_util.js';
import router from '../../config/routes';
import store from '../../vuex/store';
import VueImg from 'v-img';
import Util from '../../common/util.js';
import Wcontext from './context.js';
import components from '../../components/'; //加载公共组件
import directives from '../../directives/'; //加载公共指令
import VCharts from 'v-charts';
import { sync } from 'vuex-router-sync';
//import 'iview/dist/styles/iview.css';
//定制皮肤
import '../../assets/theme/dark.less';
import '../../assets/css/base.css';
import i18n from '../../components/i18n/i18n.js';
import locale from 'iview/dist/locale/en-US';

Vue.use(iView, { locale });
Vue.use(Vue2Filters);
Vue.use(VueImg);
Vue.use(VCharts);
sync(store, router);

window.PROJECT_NAME = Util.projectName();

//注册VUE全局对象
Vue.prototype.axios = axios;
Vue.prototype.i18n=i18n;

//触发用户初始化服务(使用同步请求保证在所有之前初始化用户信息)
Wcontext.init();

//注册公共组件
Object.keys(components).forEach((key) => {
    var name = key.replace(/(\w)/, (v) => v.toUpperCase()) //首字母大写
//  console.log(`ws${name}`);
    Vue.component(`ws${name}`, components[key])
});


//注册公共指令
Object.keys(directives).forEach((key) => {
    Vue.directive(key, directives[key])
});


new Vue({
    el: '#app',
    router,
    store,
    i18n,
    render: h => h(App)
});


